<?php

class ServiceUserController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    }

    public function indexAction()
    {
		
   	
    $users = new ServiceUserModel();
   	$order = 'ServiceUser_ID DESC';
   	
   	$this->view->users = $users->fetchAll(null, $order);
   	
   	
    
  
    
    }

    public function requestAction()
    {
        // action body
    }

    public function changeConstraintsAction()
    {
        // action body
    }

    public function changeUserDataAction()
    {
        // action body
    }

    public function viewAction()
    {
       
    }

    public function deleteAction()
    {
        // action body
    }

    public function createAction()
    {
       $params = array();
       
       // Parameter für das create Fomular
       $params['ServiceUser']['ServiceUser_name']='';
       $params['ServiceUser']['ServiceUser_password']='';
       $params['ServiceUser']['ServiceUser_info']='';
       $params['errors'] = array();
       
       // Übergabe der Parameter
       foreach($params as $key => $value){
    		$this->view->assign($key, $value);
    	}
    	
    	
    	
    	$this->view->assign('form_action', 'save-user');
  
    }
    
    public function saveUserAction()
    {
    	
    	
    	$data['ServiceUser_name']= $_POST['ServiceUser_name'];
    	$data['ServiceUser_password'] = $_POST['ServiceUser_password'];
    	$data['ServiceUser_info'] = $_POST['ServiceUser_info'];
    	
    	$user = new ServiceUserModel();
    	
    	$user_id = $user->insert($data);
    	
    	$url = 'service-user/';
    	
    	$this->_redirect($url);
    	
    }
    
  

}













